<!DOCTYPE HTML>
<html>
<head>
    <title></title>
</head>
<style>
.src {
    display: flex;
}
.dropabled {
    flex: 1;
}
.img {
    width: 100px;
    height: 100px;
    border: 1px solid gray;
}
.target {
    width: 200px;
    height: 200px;
    line-height: 200px;
    text-align: center;
    border: 1px solid gray;
}
</style>
<body>
    <div class="src">
        <div class="dragabled">
            <div class="txt" id="txt">
             文字拖拽
                <p draggable="true">文字设置</p>  
            </div>
            <div class="url" id="url">
            <a href="http://weiqinl.com" target="_blank">我是</a>
            </div>
            <img class="img" id="tupian1" src="img1.png"/>
            <img class="img" id="tupian2" src="img2.png"/>
        </div>
        <div id='target' class="dropabled target">1</div>
    </div>
    <script>
        var dragSrc = document.getElementById('txt')
        var target = document.getElementById('target')
        dragSrc.ondragstart = handle_start
        dragSrc.ondrag = handle_drag
        dragSrc.ondragend = handle_end
        function handle_start(e) {
          console.log('拖动时候')
        }
      function handle_drag() {
            console.log('拖动时候')
        }
      function handle_end() {
            console.log('拖动操作')
        }
        target.ondragenter = handle_enter
        target.ondragover = handle_over
        target.ondragleave = handle_leave
        target.ondrop = handle_drop
        function handle_enter(e) {
            console.log('进入目的地')
            e.preventDefault()
        }
        function handle_over(e) {
            console.log('在目的地时')
            e.preventDefault()
        }
        function handle_leave(e) {
            console.log('离开目的地')
        }
        function handle_drop(e) {
            console.log('在目的地放下')
            var t = Date.now()
            target.innerHTML = ''
            target.append(t + '拖放的事件。')
            e.preventDefault()
        }
    </script>
</body>
</html>
